ng911ok.lib.session module#
Reads in configuration data from config.yml.
- authors:
Riley Baird (OK), Emma Baker (OK)
- created:
August 20, 2024
- modified:
May 12, 2025
- class _NG911Config(gdb_info: NG911GeodatabaseInfo, domains: NG911DomainNamespace, fields: NG911FieldNamespace, feature_classes: NG911FeatureClassNamespace)#
Bases:
YAMLObjectClass containing data from
config.yml.- yaml_loader#
alias of
SafeLoader
- classmethod from_yaml(loader: SafeLoader, node: Node)#
Convert a representation node to a Python object.
- _match_names(target: Literal['DOMAINS', 'FIELDS', 'FEATURE_CLASSES'], names: Sequence[str], on_mismatch: Literal['DROP', 'ERROR', 'NONE'] = 'DROP') list[str | None]#
- get_closest_field_name(name: str, fields: Collection[NG911Field | str] | None = None) str | None#
Attempts to find the closest field name to name out of those in fields. Case and underscores are ignored during matching. If fields is
None, all field names are considered. If the match is acceptably close, the match is returned (with the correct case). Otherwise, returnsNone.- Parameters:
name (str) – The field name to search for
fields (Optional[Collection[NG911Field | str]]) – Optional list of
NG911Fieldobjects or field names to consider; default None
- Returns:
The closest field name or
None- Return type:
str | None
- get_domain_by_name(name: str, case_sensitive: bool = True) NG911Domain#
Returns the instance of
NG911Domainfromself.domainswith anameattribute equal to name.- Parameters:
name (str) –
nameattribute of the domaincase_sensitive (bool) – Whether the case of
namemust match that of the domain, default True
- Returns:
Domain with the given name
- Return type:
- get_feature_class_by_name(name: str, case_sensitive: bool = True) NG911FeatureClass#
Returns the instance of
NG911FeatureClassfromself.feature_classeswith anameattribute equal to name.This is an alternative to selecting a feature class by its
roleattribute, which, given a feature class with role “role_value”, would normally be done asself.feature_classes.role_valueorself.feature_classes["role_value"].- Parameters:
name (str) –
nameattribute of the feature classcase_sensitive (bool) – Whether the case of
namemust match that of the feature class, default True
- Returns:
Feature class with the given name
- Return type:
- get_field_by_name(name: str, case_sensitive: bool = True) NG911Field#
Returns the instance of
NG911Fieldfromself.fieldswith anameattribute equal to name.This is an alternative to selecting a field by its
roleattribute, which, given a field with role “role_value”, would normally be done asself.fields.role_valueorself.fields["role_value"].- Parameters:
name (str) –
nameattribute of the fieldcase_sensitive (bool) – Whether the case of
namemust match that of the field, default True
- Returns:
Field with the given name
- Return type:
- match_domain_names(names: Sequence[str], on_mismatch: Literal['DROP', 'ERROR', 'NONE'] = 'DROP') list[str | None]#
Given a case-insensitive sequence of domain names, return a list of the corresponding correctly-cased domain names.
Valid values for on_mismatch are:
“DROP”: Silently skip the name
“ERROR”: Raise a ValueError
“NONE”: Append
Noneto the results
- Parameters:
names (Sequence[str]) – Case-insensitive names to match
on_mismatch (Literal["DROP", "ERROR", "NONE"]) – Behavior if no match is found; default “DROP”
- Returns:
list[str | None]
- match_feature_class_names(names: Sequence[str], on_mismatch: Literal['DROP', 'ERROR', 'NONE'] = 'DROP') list[str | None]#
Given a case-insensitive sequence of feature class names, return a list of the corresponding correctly-cased feature class names.
Valid values for on_mismatch are:
“DROP”: Silently skip the name
“ERROR”: Raise a ValueError
“NONE”: Append
Noneto the results
- Parameters:
names (Sequence[str]) – Case-insensitive names to match
on_mismatch (Literal["DROP", "ERROR", "NONE"]) – Behavior if no match is found; default “DROP”
- Returns:
list[str | None]
- match_field_names(names: Sequence[str], on_mismatch: Literal['DROP', 'ERROR', 'NONE'] = 'DROP') list[str | None]#
Given a case-insensitive sequence of field names, return a list of the corresponding correctly-cased field names.
Valid values for on_mismatch are:
“DROP”: Silently skip the name
“ERROR”: Raise a ValueError
“NONE”: Append
Noneto the results
- Parameters:
names (Sequence[str]) – Case-insensitive names to match
on_mismatch (Literal["DROP", "ERROR", "NONE"]) – Behavior if no match is found; default “DROP”
- Returns:
list[str | None]
- domains: NG911DomainNamespace#
Object containing information about the domains specified in the Standards. The namespace is designed to facilitate autocompletion.
- feature_class_info: dict[str, IterableNamespace[str | list[str]]]#
Dictionary of feature class information: name, geometry_type, fields (list)
Deprecated since version 3.0.0-alpha.2: Use
feature_classesinstead.
- feature_classes: NG911FeatureClassNamespace#
Object containing information about the feature class schemas specified in the Standards. The namespace is designed to facilitate autocompletion.
- field_info: dict[str, IterableNamespace[str | int | IterableNamespace[str | dict[str, str]] | None]]#
Dictionary of all fields with field properties
Deprecated since version 3.0.0-alpha.2: Use
fieldsinstead.
- field_names: FrozenList[str]#
Returns a list of all of names (not roles) of all fields.
- fields: NG911FieldNamespace#
Object containing information about the fields specified in the Standards. The namespace is designed to facilitate autocompletion.
- gdb_info: NG911GeodatabaseInfo#
Object containing information that applies to the geodatabase or to multiple items therein.
- optional_feature_class_names: FrozenList[str]#
Returns a list of the names (not roles) of feature classes that are allowed in the optional feature dataset.
- required_feature_class_names: FrozenList[str]#
Returns a list of the names (not roles) of feature classes that belong in the required feature dataset.
- street_field_names: FrozenList[str]#
Returns a list of the names (not roles) of all the
NG911Fieldobjects relevant to computing the full name of aROAD_CENTERLINEfeature. Legacy fields are not included.
- street_fields: FrozenList[NG911Field]#
Returns a list of all the
NG911Fieldobjects relevant to computing the full name of aROAD_CENTERLINEfeature. Legacy fields are not included.
- yaml_tag = '!NG911Config'#
- _construct_domain_namespace(loader: Loader, node: Node) NG911DomainNamespace#
- _construct_feature_class(loader: Loader, tag: str, node: Node) NG911FeatureClass#
- _construct_feature_class_namespace(loader: Loader, node: Node) NG911FeatureClassNamespace#
- _construct_field_namespace(loader: Loader, node: Node) NG911FieldNamespace#
- config: _NG911Config = <ng911ok.lib.session._NG911Config object>#
The single instance of
_NG911Config, containing data from the configuration fileconfig.yml.